package com.gongyou.forum.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gongyou.common.pojo.Yuepai;
import com.gongyou.forum.mapper.YuePaiMapper;
import com.gongyou.forum.service.YuePaiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author LiQuanPing
 * @Date 2021-03-21 16:55
 * @Version 1.8
 * @creed: ♂♂Talk is cheap,show me the code♀♀
 */
@Service
public class YuePaiServiceImpl implements YuePaiService {

    @Autowired
    private YuePaiMapper yuePaiMapper;

    //读取所有约拍信息
    @Override
    public List getAllYuePaiInfo() {

        List<Yuepai> yuepaiList = yuePaiMapper.selectList(new QueryWrapper<Yuepai>().orderByDesc("pub_date"));
        for (Yuepai yuepai : yuepaiList) {
            List list = JSON.parseObject(yuepai.getUrls(), List.class);
            yuepai.setUrlsList(list);
        }

        return yuepaiList;
    }
}
